/**
 * 公众号设置
 */
define(function (require, exports, module) {
    require('authorize');
    var util = require('util');
    var ui = require('ui');
    var common = require('./common');
    var angular = require("angular");
    require("angular-route");
    require("angular-ui");
    require("angular-messages");
    require('./public_rule_agreement');
    require('./public_registration_review');
    require('./public_invite_broker');
    require('./public_channel_identity');
    require('./public_banks_borrow');
    require('permission');

    angular.module('app', ['ngRoute', 'ngMessages', 'ngUI', 'PublicRuleAgreement', 'PublicRegistrationReview', 'PublicInviteBroker', 'PublicChannelIdentity', 'PublicBanksBorrow'])
        .config(['$routeProvider', function ($routeProvider) {
            $routeProvider
                .when('/rule_agreement', {templateUrl: 'inc/rule_agreement.html'})
                .when('/registration_review', {templateUrl: 'inc/registration_review.html'})
                .when('/invite_broker', {templateUrl: 'inc/invite_broker.html'})
                .when('/channel_identity', {templateUrl: 'inc/channel_identity.html'})
                .when('/banks_borrow', {templateUrl: 'inc/banks_borrow.html'})
                .otherwise({redirectTo: '/rule_agreement'});
        }])
        .controller('MainController', ['$rootScope', '$scope', '$location',
            function ($rootScope, $scope, $location) {
                $scope.tabs = [
                    {value: '/rule_agreement', name: '规则协议地址'},
                    {value: '/registration_review', name: '注册审核'},
                    {value: '/invite_broker', name: '邀请经纪人'},
                    {value: '/channel_identity', name: '渠道身份管理'},
                    {value: '/banks_borrow', name: '结佣银行管理'}
                ];
                $scope.current = $location.path();
                $rootScope.$on('$routeChangeSuccess', function () {
                    $scope.current = $location.path();
                });
            }
        ])

    angular.bootstrap(document, ['app']);
});